#pragma once

#include <mutex>
#include <memory>
#include <mqtt_client_cpp.hpp>

class mqttplus{
public:
    boost::asio::io_context io;
    static std::shared_ptr<mqttplus> _inst;
    std::shared_ptr<
        MQTT_NS::callable_overlay<
            MQTT_NS::sync_client<
                MQTT_NS::tcp_endpoint<
                    boost::asio::ip::tcp::socket,
                    MQTT_NS::strand
                >
            >
        >
    > c;
    static std::shared_ptr<mqttplus> inst(){
        if(_inst==nullptr)
            _inst.reset(new mqttplus());
        return _inst;
    }
    bool publish(std::string topic,std::string msg);
protected:
    mqttplus();

    std::mutex mtx;
};